#include "..\headers\ListOf.h"
#define MAXSIZE 100

typedef char ElemType;

typedef struct Stack {
  ElemType *top;
  ElemType *base;
  int StackSize;
} SymbolStack;

int InitStack(SymbolStack &stack) {
  stack.base = (ElemType *)malloc(sizeof(Stack) * MAXSIZE);
  if (!stack.base) {
    return ERROR;
  }
  stack.top = stack.base;
  stack.StackSize = MAXSIZE;
  return OK;
}

int Push(SymbolStack &S, ElemType e) {
  if (S.top - S.base == S.StackSize) {
    return ERROR;
  }
  *S.top++ = e;
  return OK;
}

// pop the top element
char Pop(SymbolStack &S) {
  if (S.top == S.base) {
    return '0';
  }
  S.top--;
  char e = *S.top;
  return e;  // return pop element
}

bool Match(char L, char R) {
  if (L == '(' && R == ')') return true;
  if (L == '[' && R == ']') return true;
  if (L == '{' && R == '}') return true;
  return false;
}

bool EmptyStack(SymbolStack S) { return S.base == S.top; }

char GetTop(SymbolStack S) {
  char e;
  if (S.top == S.base) {
    return '0';
  }
  S.top--;
  e = *S.top;
  return e;
}

void CheckMatchSymbols(char sourceCode[]) {
  char error = '0';
  SymbolStack sy;
  InitStack(sy);
  int i = 0;
  while (sourceCode[i] != '\0') {
    if (sourceCode[i] == '\n') {
      i++;
      continue;
    }
    // judge /* */
    if (sourceCode[i] == '/' && sourceCode[i + 1] == '*') {
      Push(sy, 'a');
      i++;
    }  // end if
    else if (sourceCode[i] == '*' && sourceCode[i + 1] == '/') {
      if (Pop(sy) != 'a') {
        error = 'b';
        break;
      }
      i++;
    }  // end if
    // judge () {} []
    else if (sourceCode[i] == '(' || sourceCode[i] == '[' ||
             sourceCode[i] == '{')
      Push(sy, sourceCode[i]);
    else if (sourceCode[i] == ')' || sourceCode[i] == ']' ||
             sourceCode[i] == '}') {
      char e = GetTop(sy);
      if (EmptyStack(sy) || !Match(e, sourceCode[i])) {
        error = sourceCode[i];
        break;
      }  // end if
      Pop(sy);
    }  // end else if
    i++;
  }  // end while

  if (error == '0' && EmptyStack(sy)) {
    printf("YES");
    return;
  } else {
    printf("NO\n");
    if (!EmptyStack(sy)) {
      if (GetTop(sy) == '(' || GetTop(sy) == '[' || GetTop(sy) == '{') {
        printf("%c-?", GetTop(sy));
        return;
      }
      if (GetTop(sy) == 'a') {
        printf("/*-?");
        return;
      }
    }  // end if
    else {
      if (error != 'b')
        printf("?-%c", error);
      else
        printf("?-*/");
      return;
    }
  }  // end if
}

int main() {
  char sourceCode[MAXSIZE * 100];
  char line[MAXSIZE];

  // if read "." break
  int i = 0;
  while (fgets(line, sizeof(line), stdin) != NULL) {
    if (line[0] == '.') {
      break;
    }
    for (int j = 0; line[j] != '\0'; j++) {
      sourceCode[i++] = line[j];
    }
  }
  CheckMatchSymbols(sourceCode);

  return 0;
}
